package com.dingwei.superiordiary.adapter.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.dingwei.superiordiary.R;
import com.dingwei.superiordiary.app.MyApplication;
import com.dingwei.superiordiary.bean.Index_Bean;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.lihao.baselibrary.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by lihao on 2018/1/8.
 */

public class SelectedListAdapter extends RecyclerArrayAdapter<Index_Bean.DataBean.ProductBean> {
    public SelectedListAdapter(Context context) {
        super(context);
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new SelectedHolder(parent);
    }

    class SelectedHolder extends BaseViewHolder<Index_Bean.DataBean.ProductBean> {

        @Bind(R.id.img)
        ImageView img;
        @Bind(R.id.tv_title)
        TextView tvTitle;
        @Bind(R.id.tv_look)
        TextView tvLook;
        @Bind(R.id.tv_like)
        TextView tvLike;
        @Bind(R.id.tv_collect)
        TextView tvCollect;
        @Bind(R.id.tv_type)
        TextView tvType;

        public SelectedHolder(ViewGroup parent) {
            super(parent, R.layout.item_goods);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void setData(Index_Bean.DataBean.ProductBean data) {
            super.setData(data);
            Glide.with(BaseActivity.context)
                    .load(data.icon)
                    .apply(MyApplication.options)
                    .into(img);
            tvTitle.setText(data.name);
            tvLook.setText(data.viewed + "");
            tvLike.setText(data.likes + "");
            tvCollect.setText(data.collection + "");
            tvType.setText(data.category+"");
        }
    }
}
